babl/babl-classes.h babl/babl-conversion.c babl/babl-fish-path.c
authorKevin Cozens <kcozens@cvs.gnome.org>
Mon, 11 Sep 2006 04:37:43 +0000 (04:37 +0000)
committerKevin Cozens <kcozens@src.gnome.org>
Mon, 11 Sep 2006 04:37:43 +0000 (04:37 +0000)
2006-09-10  Kevin Cozens  <kcozens@cvs.gnome.org>

* babl/babl-classes.h
* babl/babl-conversion.c
* babl/babl-fish-path.c
* babl/babl-fish-stats.c
* babl/babl-internal.c: Tick times are in usecs not msecs. Use longs
to hold tick values.

* babl/babl-util.h:
* babl/babl-util.c (babl_ticks): Fixed calculation of time (usecs
not msecs). Changed declaration to return a long not unsigned int.

ChangeLog
babl/babl-classes.h
babl/babl-conversion.c
babl/babl-fish-path.c
babl/babl-fish-stats.c
babl/babl-internal.c
babl/babl-util.c
babl/babl-util.h

index 256a1b79858ece04978205fea825b6931fe109c5..4235d8ebe7cd25d8c32406c2da62501c2c63f528 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2006-09-10  Kevin Cozens  <kcozens@cvs.gnome.org>
+
+       * babl/babl-classes.h
+       * babl/babl-conversion.c
+       * babl/babl-fish-path.c
+       * babl/babl-fish-stats.c
+       * babl/babl-internal.c: Tick times are in usecs not msecs. Use longs
+       to hold tick values.
+
+       * babl/babl-util.h:
+       * babl/babl-util.c (babl_ticks): Fixed calculation of time (usecs
+       not msecs). Changed declaration to return a long not unsigned int.
+
 2006-09-09  Øyvind Kolås  <pippin@gimp.org>
 
        * extensions/Makefile.am: moved -fPIC from LD_FLAGS to CFLAGS.
index 24ca3db55979b0940f4739e8e376616ac14ecc3e..7f83ba9cb2cca6a24767781c5d81d692f3b4220f 100644 (file)
@@ -93,7 +93,7 @@ BablConversion {
   BablInstance           instance;
   union Babl            *source;
   union Babl            *destination;
-  int                    cost;
+  long                   cost;
   double                 error;
   union
     {
@@ -171,7 +171,7 @@ typedef struct
   BablModel       *model;
   int              bytes_per_pixel;
   int              planar;
-  double           loss; /*< average relative error when converting 
+  double           loss; /*< average relative error when converting
                              from and to RGBA double */
 } BablFormat;
 
@@ -202,7 +202,7 @@ typedef struct
   /* instrumentation */
   int             processings; /* number of times the fish has been used */
   long            pixels;      /* number of pixels translates */
-  long            msecs;       /* msecs spent within this fish */
+  long            usecs;       /* usecs spent within this fish */
 } BablFish;
 
 
@@ -242,7 +242,7 @@ typedef struct
   BablConversion  *conversion[BABL_HARD_MAX_PATH_LENGTH];
 } BablFishPath;
 
-/* BablFishReference 
+/* BablFishReference
  *
  * A BablFishReference is not intended to be fast, thus the algorithm
  * encoded can use a multi stage approach, based on the knowledge babl
@@ -264,7 +264,7 @@ typedef struct
 {
   BablInstance   instance; /* path to .so / .dll is stored in instance name */
   void          *dl_handle;
-  void         (*destroy) (void); 
+  void         (*destroy) (void);
 } BablExtension;
 
 typedef union
index 53721d57952b918bb9a549e6db4f3043fb13854a..88ebafd36934960ead1795333d6806ef0a920613 100644 (file)
@@ -23,7 +23,7 @@
 #include <stdarg.h>
 #include <math.h>
 
-static int 
+static int
 each_babl_conversion_destroy (Babl *babl,
                               void *data)
 {
@@ -37,7 +37,7 @@ conversion_new (const char        *name,
                 Babl              *source,
                 Babl              *destination,
                 BablFuncLinear     linear,
-                BablFuncPlane      plane, 
+                BablFuncPlane      plane,
                 BablFuncPlanar     planar)
 {
   Babl *babl = NULL;
@@ -101,7 +101,7 @@ conversion_new (const char        *name,
   babl->conversion.source      = (union Babl*)source;
   babl->conversion.destination = (union Babl*)destination;
   babl->conversion.error       = -1.0;
-  babl->conversion.cost        = 69;
+  babl->conversion.cost        = 69L;
 
   babl->conversion.pixels      = 0;
   babl->conversion.processings = 0;
@@ -131,7 +131,7 @@ conversion_new (const char        *name,
          }
        babl_conversion_new (
           src_format,
-          dst_format, 
+          dst_format,
           "linear", linear,
           NULL);
        babl->conversion.error = 0.0;
@@ -194,21 +194,21 @@ babl_conversion_new (void *first_arg,
 
   assert (BABL_IS_BABL(source));
   assert (BABL_IS_BABL(destination));
-  
-  
+
+
   while (arg)
     {
-     
+
       if (!strcmp (arg, "id"))
         {
           id = va_arg (varg, int);
         }
-      
+
       else if (!strcmp (arg, "linear"))
         {
           if (got_func++)
             {
-              babl_fatal ("already got a conversion func\n"); 
+              babl_fatal ("already got a conversion func\n");
             }
           linear = va_arg (varg, BablFuncLinear);
         }
@@ -217,7 +217,7 @@ babl_conversion_new (void *first_arg,
         {
           if (got_func++)
             {
-              babl_fatal ("already got a conversion func\n"); 
+              babl_fatal ("already got a conversion func\n");
             }
           plane = va_arg (varg, BablFuncPlane);
         }
@@ -226,7 +226,7 @@ babl_conversion_new (void *first_arg,
         {
           if (got_func++)
             {
-              babl_fatal ("already got a conversion func\n"); 
+              babl_fatal ("already got a conversion func\n");
             }
           planar = va_arg (varg, BablFuncPlanar);
         }
@@ -238,7 +238,7 @@ babl_conversion_new (void *first_arg,
 
       arg = va_arg (varg, char *);
     }
-    
+
   va_end   (varg);
 
   assert (source);
@@ -259,7 +259,7 @@ babl_conversion_new (void *first_arg,
   babl = conversion_new (create_name (source, destination, type),
        id, source, destination, linear, plane, planar);
 
-  { 
+  {
     Babl *ret = babl_db_insert (db, babl);
     if (ret!=babl)
         babl_free (babl);
@@ -301,14 +301,14 @@ babl_conversion_planar_process (BablConversion *conversion,
 #ifdef USE_ALLOCA
   void **src_data = alloca (sizeof (void*) * source->components);
   void **dst_data = alloca (sizeof (void*) * destination->components);
-#else 
+#else
   void *src_data[BABL_MAX_COMPONENTS];
   void *dst_data[BABL_MAX_COMPONENTS];
 #endif
 
   memcpy (src_data, source->data, sizeof (void*) * source->components);
   memcpy (dst_data, destination->data, sizeof (void*) * destination->components);
-  
+
   return conversion->function.planar (source->components,
                                       src_data,
                                       source->pitch,
@@ -340,7 +340,7 @@ babl_conversion_process (Babl *babl,
         if (BABL_IS_BABL(source))
           {
             BablImage *img;
-           
+
             img       = (BablImage*)source;
             src_data  = img->data[0];
             src_pitch = img->pitch[0];
@@ -348,7 +348,7 @@ babl_conversion_process (Babl *babl,
         if (BABL_IS_BABL(destination))
           {
             BablImage *img = (BablImage*)destination;
-           
+
             dst_data  = img->data[0];
             dst_pitch = img->pitch[0];
           }
@@ -373,18 +373,18 @@ babl_conversion_process (Babl *babl,
       babl_assert (BABL_IS_BABL (destination));
 
       babl_conversion_planar_process (                  conversion,
-                                      (BablImage*)      source, 
+                                      (BablImage*)      source,
                                       (BablImage*)      destination,
                                                         n);
       break;
     case BABL_CONVERSION_LINEAR:
-      /* the assertions relied on a babl_malloc structure 
+      /* the assertions relied on a babl_malloc structure
        *
        * babl_assert (!BABL_IS_BABL (source));
       babl_assert (!BABL_IS_BABL (destination));*/
 
       babl_conversion_linear_process (conversion,
-                                      source, 
+                                      source,
                                       destination,
                                       n);
       break;
@@ -409,7 +409,7 @@ test_create (void)
 {
   double *test;
   int     i;
-  
+
   srandom (20050728);
 
   test = babl_malloc (sizeof (double) * test_pixels * 4);
@@ -423,12 +423,12 @@ long
 babl_conversion_cost (BablConversion *conversion)
 {
   if (!conversion)
-    return 100000000.0;
+    return 100000000L;
   if (conversion->error==-1.0)
     babl_conversion_error (conversion);
   return conversion->cost;
 }
-  
+
 double
 babl_conversion_error (BablConversion *conversion)
 {
@@ -445,10 +445,10 @@ babl_conversion_error (BablConversion *conversion)
        NULL);
 
   double   error = 0.0;
-  unsigned int ticks_start = 0;
-  unsigned int ticks_end   = 0;
-  double  *test; 
+  long     ticks_start = 0;
+  long     ticks_end   = 0;
+
+  double  *test;
   void    *source;
   void    *destination;
   double  *destination_rgba_double;
@@ -488,7 +488,7 @@ babl_conversion_error (BablConversion *conversion)
     {
       return conversion->error;
     }
-  
+
   test=test_create ();
 
 
@@ -497,7 +497,7 @@ babl_conversion_error (BablConversion *conversion)
   ref_destination = babl_calloc (test_pixels, fmt_destination->format.bytes_per_pixel);
   destination_rgba_double     = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
   ref_destination_rgba_double = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
-  
+
   babl_process (fish_rgba_to_source,
       test, source, test_pixels);
 
@@ -526,7 +526,7 @@ babl_conversion_error (BablConversion *conversion)
   fish_reference->fish.pixels -= test_pixels;
   fish_destination_to_rgba->fish.pixels -= 2 * test_pixels;
 
-  
+
   babl_free (source);
   babl_free (destination);
   babl_free (destination_rgba_double);
index 092ca6c02c860110d46f236f446a8455510d28ec..d3e4428cb2963eb0bc7fe75d6ff97106a574d96c 100644 (file)
@@ -147,7 +147,7 @@ get_conversion_chain (Babl             *from,
           format.from)
 
          babl_list_each (
-           (void **) 
+           (void **)
            BABL(temp_chain[temp_conversions-1]->destination)->
            format.from,
            chain_gen_each,
@@ -185,7 +185,7 @@ chain_gen_each (Babl *babl,
       if ((BABL(babl->conversion.destination) == c->to) )
         {
           /* a candidate path has been found */
-        
+
           double    temp_cost  = 0.0;
           double    temp_error = 1.0;
           int       i;
@@ -195,11 +195,11 @@ chain_gen_each (Babl *babl,
               temp_error *= (1.0+babl_conversion_error (c->temp_chain[i]));
               temp_cost  += babl_conversion_cost (c->temp_chain[i]);
             }
-          
+
           if (temp_cost <  *c->best_cost         &&
               temp_error - 1.0 <= legal_error()  &&   /* this check before the next; which does a more accurate
                                                          measurement of the error */
-              (temp_error=chain_error (c->from, c->to, c->temp_chain, c->temp_conversions+1)) <= legal_error() 
+              (temp_error=chain_error (c->from, c->to, c->temp_chain, c->temp_conversions+1)) <= legal_error()
              )
             {
               int i;
@@ -292,7 +292,7 @@ babl_fish_path (Babl   *source,
 
   babl->fish.processings = 0;
   babl->fish.pixels      = 0;
-  babl->fish.msecs       = 0;
+  babl->fish.usecs       = 0;
   babl->fish.error       = 200000;
 
   babl->fish_path.cost        = 200000;
@@ -302,7 +302,7 @@ babl_fish_path (Babl   *source,
 
   babl_assert (source->class_type == BABL_FORMAT);
   babl_assert (destination->class_type == BABL_FORMAT);
-  
+
   get_conversion_chain (source,
                         destination,
                         &babl->fish_path.cost,
@@ -311,7 +311,7 @@ babl_fish_path (Babl   *source,
                         (BablConversion**)(babl->fish_path.conversion),
                         &babl->fish_path.conversions,
                         temp_chain,
-                        0, 
+                        0,
                         max_path_length ());
 
   if (babl->fish_path.conversions==0)
@@ -319,8 +319,8 @@ babl_fish_path (Babl   *source,
       babl_free (babl);
       return NULL;
     }
-  
-  { 
+
+  {
     Babl *ret = babl_db_insert (babl_fish_db (), babl);
     if (ret!=babl)
         babl_free (babl);
@@ -338,15 +338,15 @@ chain_process (BablConversion *chain[],
   void *bufA = NULL;
   void *bufB = NULL;
   int   i;
-  
+
   babl_assert (source);
   babl_assert (destination);
-  
+
   if (conversions > 1)
     bufA = babl_malloc (n * sizeof (double) * 5);
   if (conversions > 2)
     bufB = babl_malloc (n * sizeof (double) * 5);
-  
+
   for (i=0; i<conversions; i++)
     {
       if (i==0 && conversions == 1)
@@ -422,7 +422,7 @@ test_create (void)
 {
   double *test;
   int     i;
-  
+
   srandom (20050728);
 
   test = babl_malloc (sizeof (double) * test_pixels * 4);
@@ -449,8 +449,8 @@ chain_error (Babl            *fmt_source,
        NULL);
 
   double   error = 0.0;
-  double  *test; 
+
+  double  *test;
   void    *source;
   void    *destination;
   double  *destination_rgba_double;
@@ -469,8 +469,8 @@ chain_error (Babl            *fmt_source,
   ref_destination = babl_calloc (test_pixels, fmt_destination->format.bytes_per_pixel);
   destination_rgba_double     = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
   ref_destination_rgba_double = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
- /* create sourcebuffer from testbuffer in the correct format */ 
+
+ /* create sourcebuffer from testbuffer in the correct format */
   babl_process (fish_rgba_to_source,
       test, source, test_pixels);
 
index e02e6d3770eafce5a85f0c881e8ea7d9f9dd47f6..66403a2f35f86759afe9651a9e63e1279ee5a1d7 100644 (file)
@@ -42,11 +42,11 @@ table_destination_each (Babl *babl,
 
       babl_assert (fish);
 
-      
+
       switch (fish->class_type)
         {
           case BABL_FISH_PATH:
-            
+
             fprintf (output_file, "<td class='cell'%s><a href='javascript:o()'>%s",
                fish->fish.processings > 0 ? " style='background-color: #69f'":"",
             utf8_bar[fish->fish_path.conversions]);
@@ -57,7 +57,7 @@ table_destination_each (Babl *babl,
               fprintf (output_file, "<h3><span class='g'>path</span> %s <span class='g'>to</span> %s</h3>", source->instance.name, destination->instance.name);
               if (fish->fish.processings > 0)
                 {
-                  fprintf (output_file, "<span class='g'>msecs:</span>%li<br/>", fish->fish.msecs);
+                  fprintf (output_file, "<span class='g'>usecs:</span>%li<br/>", fish->fish.usecs);
                   fprintf (output_file, "<span class='g'>Processings:</span>%i<br/>", fish->fish.processings);
                   fprintf (output_file, "<span class='g'>Pixels:</span>%li<br/>", fish->fish.pixels);
                 }
@@ -96,7 +96,7 @@ table_destination_each (Babl *babl,
 
               if (fish->fish.processings > 0)
                 {
-                  fprintf (output_file, "<span class='g'>msecs:</span>%li<br/>", fish->fish.msecs);
+                  fprintf (output_file, "<span class='g'>usecs:</span>%li<br/>", fish->fish.usecs);
                   fprintf (output_file, "<span class='g'>Processings:</span>%i<br/>", fish->fish.processings);
                   fprintf (output_file, "<span class='g'>Pixels:</span>%li<br/>", fish->fish.pixels);
                 }
@@ -144,7 +144,7 @@ table_source_each (Babl *babl,
             break;
         }
     }
-  
+
   fprintf (output_file, "<tr>");
   fprintf (output_file, "<td class='format_name'><a href='javascript:o();'>%s", expanded_name);
   {
@@ -201,7 +201,7 @@ each_conv (Babl *babl,
   fprintf (output_file, "<em>error:</em> %f <em>cost:</em> %4.0f <em>processings:</em> %i <em>pixels:</em> %li", error, cost,
             babl->conversion.processings, babl->conversion.pixels);
   fprintf (output_file, "</dd>");
-   
+
   return 0;
 }
 
@@ -218,7 +218,7 @@ babl_fish_stats (FILE *file)
 {
   output_file = file;
 
-  fprintf (output_file, 
+  fprintf (output_file,
 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
 "<html>\n"
index 73af0127f65689f34283618df5dabbe8419d6867..46bd660a1020f8c5d012ac1ad9e5d0b134c4b45c 100644 (file)
@@ -91,7 +91,7 @@ babl_process (Babl *babl,
   if (babl->class_type >= BABL_CONVERSION &&
       babl->class_type <= BABL_CONVERSION_PLANAR)
     return babl_conversion_process (babl, source, destination, n);
-  
+
   if (babl->class_type == BABL_FISH ||
       babl->class_type == BABL_FISH_REFERENCE ||
       babl->class_type == BABL_FISH_PATH ||
@@ -102,9 +102,9 @@ babl_process (Babl *babl,
        ret = babl_fish_process (babl, source, destination, n);
 
        ticks -= babl_ticks();
-       ticks *= -1;
+       ticks *= -1L;
 
-       babl->fish.msecs += ticks;
+       babl->fish.usecs += ticks;
        babl->fish.processings++;
        babl->fish.pixels += ret;
        return ret;
index 032ee600f6ff5db58fb7669af50133597a7980f1..8ba72782efa34ad8eb06bc700668d1af9046e1e0 100644 (file)
@@ -28,7 +28,7 @@ static int list_length (void **list)
 {
   void **ptr;
   int    len=0;
-  
+
   ptr = list;
   while (NULL!=*ptr)
     {
@@ -43,13 +43,13 @@ babl_add_ptr_to_list (void ***list,
                       void   *new)
 {
   int orig_len=0;
+
   if (*list)
     {
       orig_len = list_length (*list);
     }
 
-  *list = babl_realloc ( (*list), 
+  *list = babl_realloc ( (*list),
                           sizeof(void *) * (orig_len + 2));
 
   if (!(*list))
@@ -82,7 +82,7 @@ babl_list_each (void             **list,
 static struct timeval start_time;
 static struct timeval measure_time;
 
-#define msecs(time) ((time.tv_sec-start_time.tv_sec)*10000000 + time.tv_usec)
+#define usecs(time) ((time.tv_sec-start_time.tv_sec)*1000000 + time.tv_usec)
 
 static void
 init_ticks (void)
@@ -94,12 +94,12 @@ init_ticks (void)
   gettimeofday (&start_time, NULL);
 }
 
-unsigned int
+long
 babl_ticks (void)
 {
   init_ticks ();
   gettimeofday (&measure_time, NULL);
-  return msecs(measure_time) - msecs(start_time);
+  return usecs(measure_time) - usecs(start_time);
 }
 
 double
@@ -108,7 +108,7 @@ babl_rel_avg_error (double *imgA,
                     long    samples)
 {
   double error = 0.0;
-  int i;
+  long   i;
 
   for (i=0; i<samples; i++)
       error += fabs (imgA[i] - imgB[i]);
index be6c9bcbb93463643ca7e3b96b9450410e8ef0f4..b49ca7bb1240dcf714b4ba15ec572e1b5fedd072 100644 (file)
@@ -30,7 +30,8 @@ babl_list_each (void             **list,
                 BablEachFunction   each_fun,
                 void              *user_data);
 
-unsigned int    babl_ticks (void);
+long
+babl_ticks     (void);
 
 double
 babl_rel_avg_error (double *imgA,